<script setup lang="ts">
import EventCollection from '@/pages/home/eventCollection';
import { useAppStore } from '@/store';

interface IProps {
  data: IBtnFormatsList;
  title: string;
  styleType: number;
}

const props = defineProps<IProps>();
const store = useAppStore();

// 点击事件处理
const handlePress = () => {
  EventCollection.onPress(props.data, 4);
  store.$patch({ btnInformation: { ...props.data, moduleType: 4 } as IServerBtnListBtnList });
};
</script>

<template>
  <view class="px[8px] pt-8px">
    <view class="flex justify-between items-center mb-[8px]">
      <text class="fw-bold c-text-16">{{ props.title }}</text>
      <view class="flex items-center" @click="handlePress">
        <text class="c-text-color-grey c-text-10"> 更多服务 </text>
        <i class="i-icon-park-outline:right text-[#9C9C9EFF]"></i>
      </view>
    </view>
    <view class="flex" v-if="styleType === 2">
      <view class="flex-1" v-for="item in props.data.btnListVos" :key="item.id">
        <Product :data="item" path="home" styles="box" />
      </view>
    </view>
    <template v-else>
      <Product v-for="item in props.data.btnListVos" :key="item.id" :data="item" path="home" styles="list" />
    </template>
  </view>
</template>
